package com.gc.controller.studentServlet;

import com.gc.entity.Student;
import com.gc.service.StudentService;
import com.gc.service.impl.StudentServiceImpl;
import com.gc.util.result.R;
import com.gc.vo.StuCheckShow;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "GetStuCheck", value = "/GetStuCheck")
public class GetStuCheck extends HttpServlet {
    StudentService studentService = new StudentServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create(); //按照 yyyy-MM-dd HH:mm:ss格式化。
        Student data = (Student)request.getSession().getAttribute("Data");
        List<StuCheckShow> students = studentService.StuCheckById(data.getId());
        response.getWriter().write(gson.toJson(R.ok().data(students)));
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
